﻿using System;
using System.Data.Linq;
using System.Data.Linq.Mapping;


namespace AccountHelper.Model
{
    public class AccountDataContext:DataContext
    {
        public AccountDataContext(string connectionString)
            : base(connectionString)
        { }

        // Specify a table for the to-do items.
        public Table<Money> Items;

    }

    [Table]
    public class Money:INotifyPropertyBase
    {
        private int _moneyId;
        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int MoneyId
        {
            get { return _moneyId; }
            set
            {
                if (_moneyId != value)
                {
                    NotifyPropertyChanging("MoneyId");
                    _moneyId = value;
                    NotifyPropertyChanged("MoneyId");
                }
            }
        }

        private string _chargeTile;
        [Column]
        public string ChargeTitle
        {
            get { return _chargeTile; }
            set
            {
                if (_chargeTile != value)
                {
                    NotifyPropertyChanging("ChargeTitle");
                    _chargeTile = value;
                    NotifyPropertyChanged("ChargeTitle");
                }
            }
        }

        private ChargeType _type;
        [Column]
        public ChargeType Type
        {
            get { return _type; }
            set
            {
                if (_type != value)
                {
                    NotifyPropertyChanging("Type");
                    _type = value;
                    NotifyPropertyChanged("Type");
                }
            }
        }

        private double _amount;
        [Column]
        public double Amount
        {
            get { return _amount; }
            set
            {
                if (_amount != value)
                {
                    NotifyPropertyChanging("Amount");
                    _amount = value;
                    NotifyPropertyChanged("Amount");
                }
            }
        }

        private string _chargeDate;
        [Column]
        public string ChargeDate
        {
            get { return _chargeDate; }
            set
            {
                if (_chargeDate != value)
                {
                    NotifyPropertyChanging("ChargeDate");
                    _chargeDate = value;
                    NotifyPropertyChanged("ChargeDate");
                }
            }
        }
    }

    public enum ChargeType
    {
        Cost,//支出
        Charge,//收入
    }


}
